//
//  RadioButtonFine.swift
//  I.S.A.P WT
//
//  Created by Илья Проскурнев on 07.08.2020.
//  Copyright © 2020 Илья Проскурнев. All rights reserved.
//

import Foundation
import UIKit
@IBDesignable

class RadioButtonFine: UIButton {
    override var isSelected: Bool {
        didSet {
            toggleButon()
        }
    }

    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        initialize()
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        initialize()
    }
    
    fileprivate func initialize() {
        layer.borderColor = UIColor.green.cgColor
        layer.borderWidth = 2
        layer.cornerRadius = 10
        self.toggleButon()
    }

    func toggleButon() {
        if self.isSelected {
            layer.borderWidth = 0
            layer.backgroundColor = UIColor.white.cgColor
        } else {
            layer.borderWidth = 2
            layer.backgroundColor = UIColor.black.cgColor
        }
    }
}
